
# Uno clone
MACH=arduino:avr:uno
CPU=atmega328p
PORT=/dev/ttyACM0
BAUD=115200

# Mini Pro clone
#MACH=arduino:avr:pro:cpu=16MHzatmega328
#CPU=atmega328p
#PORT=/dev/ttyUSB0
#BAUD=57600

# Nano clone
#MACH=arduino:avr:nano:cpu=atmega328
#PORT=/dev/ttyUSB1
#CPU=atmega328p
#BAUD=57600

# A Uno clone with a nastynasty CH341
#MACH=arduino:avr:uno
#CPU=atmega328p
#PORT=/dev/ttyUSB0
#BAUD=57600

HARD=/usr/share/arduino/hardware
TOOLS=/usr/share/arduino/tools

BASE=$(shell pwd)
SRC=main.c
BUILD=$(BASE)/.build
OBJ=.build/$(SRC).hex

all:
	rm -rf .build; mkdir .build 
	arduino-builder -hardware $(HARD) \
	-tools $(TOOLS) -fqbn $(MACH) \
	-build-path $(BUILD) -compile $(SRC)

upload:
	avrdude -V -F -C /etc/avrdude.conf -c arduino \
	-p $(CPU) -P $(PORT) -b $(BAUD) -U flash:w:$(OBJ)

clean:
	rm -rf $(BUILD)
